﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Continents.aspx.cs" Inherits="AspDatabases.Continents" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ListBox ID="ListBoxContinents" runat="server" AutoPostBack=true
        DataSourceID="EntityDataSourceContinents" DataTextField="Name" OnSelectedIndexChanged="OnContinentSelect"
        DataValueField="ContinentID"></asp:ListBox>
    <asp:EntityDataSource ID="EntityDataSourceContinents" runat="server" 
        ConnectionString="name=GeographyEntities" 
        DefaultContainerName="GeographyEntities" EnableFlattening="False" 
        EntitySetName="Continents">
    </asp:EntityDataSource>

    <asp:GridView ID="GridViewCountries" runat="server" AllowPaging="True" Visible="false"
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CountrieID" AutoGenerateOrderByClause="true" 
        OnSelectedIndexChanged="CountrySelected"
        DataSourceID="EntityDataSourceCountries" PageSize="5">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:BoundField DataField="Language" HeaderText="Language" 
                SortExpression="Language" />
            <asp:BoundField DataField="Population" HeaderText="Population" 
                SortExpression="Population" />
        </Columns>
    </asp:GridView>
    <asp:EntityDataSource ID="EntityDataSourceCountries" runat="server" 
        ConnectionString="name=GeographyEntities" 
        AutoGenerateOrderByClause="true"
        DefaultContainerName="GeographyEntities" EnableFlattening="False" 
        EntitySetName="Countries">
    </asp:EntityDataSource>

    <asp:ListView ID="ListViewTowns" runat="server"   Visible="False" 
        DataSourceID="EntityDataSourceTowns">
        <AlternatingItemTemplate>
            <tr style="background-color: #FAFAD2;color: #284775;">
                <td>
                    <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                </td>
                <td>
                    <asp:Label ID="PopulationLabel" runat="server" 
                        Text='<%# Eval("Population") %>' />
                </td>
           
                <td>
                    <asp:Label ID="TownIDLabel" runat="server" Text='<%# Eval("TownID") %>' />
                </td>
           
            </tr>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <tr style="background-color: #FFCC66;color: #000080;">
                <td>
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                        Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Cancel" />
                </td>
                <td>
                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                </td>
                <td>
                    <asp:TextBox ID="PopulationTextBox" runat="server" 
                        Text='<%# Bind("Population") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TownIDTextBox" runat="server" Text='<%# Bind("TownID") %>' />
                </td>
            </tr>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table runat="server" 
                style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                <tr>
                    <td>
                        No data was returned.</td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                        Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                        Text="Clear" />
                </td>
                <td>
                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                </td>
                <td>
                    <asp:TextBox ID="PopulationTextBox" runat="server" 
                        Text='<%# Bind("Population") %>' />
                </td>
                <td>
                    <asp:TextBox ID="TownIDTextBox" runat="server" Text='<%# Bind("TownID") %>' />
                </td>
            </tr>
        </InsertItemTemplate>
        <ItemTemplate>
            <tr style="background-color: #FFFBD6;color: #333333;">
                <td>
                    <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                </td>
                <td>
                    <asp:Label ID="PopulationLabel" runat="server" 
                        Text='<%# Eval("Population") %>' />
                </td>
                <td>
                    <asp:Label ID="TownIDLabel" runat="server" Text='<%# Eval("TownID") %>' />
                </td>
            </tr>
        </ItemTemplate>
        <LayoutTemplate>
            <table runat="server">
                <tr runat="server">
                    <td runat="server">
                        <table ID="itemPlaceholderContainer" runat="server" border="1" 
                            style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr runat="server" style="background-color: #FFFBD6;color: #333333;">
                                <th runat="server">
                                    Name</th>
                                <th runat="server">
                                    Population</th>
                                <th runat="server">
                                    TownID</th>
                            </tr>
                            <tr runat="server" ID="itemPlaceholder">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr runat="server">
                    <td runat="server" 
                        style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;">
                        <asp:DataPager ID="DataPager1" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                    ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <tr style="background-color: #FFCC66;font-weight: bold;color: #000080;">
                <td>
                    <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
                </td>
                <td>
                    <asp:Label ID="PopulationLabel" runat="server" 
                        Text='<%# Eval("Population") %>' />
                </td>
                <td>
                    <asp:Label ID="TownIDLabel" runat="server" Text='<%# Eval("TownID") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
    </asp:ListView>

    <asp:EntityDataSource ID="EntityDataSourceTowns" runat="server" OrderBy="it.Name"
        ConnectionString="name=GeographyEntities"  
        DefaultContainerName="GeographyEntities" EnableFlattening="False" 
        EntitySetName="Towns" Select="it.[Name], it.[Population], it.[TownID]">
    </asp:EntityDataSource>

    </form>
</body>
</html>
